# interactive updates

import shelve

from person_alternative import Person

db = shelve.open('class-shelve')
fieldnames = ('name', 'age', 'job', 'pay')

while True:
	key = raw_input('\nKey? => ')

	if not key: break

	if key in db:
		record = db[key]
	else:
		record = Person(name='?', age='?')

	for field in fieldnames:
		currval = getattr(record, field)
		newtext = raw_input('\t[%s]=%s\n\t\tnew?=>' % (field, currval))
		if newtext:
			setattr(record, field, eval(newtext))

	db[key] = record

db.close()
